package com.huirui.server.pojo.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.*;
import lombok.Data;

@Data
@Schema(description = "产品搜索参数DTO，用于接收前端传递的产品搜索条件")
public class ProductSearchDto {

    @Schema(description = "搜索关键词，可匹配产品名称、描述等字段，不能为空", example = "手机", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "搜索关键词不能为空")
    @Size(min = 1, max = 50, message = "搜索关键词长度不能超过50个字符")
    private String keyword;

    @Schema(description = "页码，从1开始，默认值为1", example = "1", minimum = "1", requiredMode = Schema.RequiredMode.REQUIRED)
    @Min(value = 1, message = "页码不能小于1")
    @NotNull(message = "页码不能为空")
    private Long page = 1L;  // 设置默认值

    @Schema(description = "每页条数，默认值为10，范围1-100", example = "10", minimum = "1", maximum = "100", requiredMode = Schema.RequiredMode.REQUIRED)
    @Min(value = 1, message = "每页条数不能小于1")
    @Max(value = 100, message = "每页条数不能大于100")
    @NotNull(message = "每页条数不能为空")
    private Long pageSize = 10L;  // 设置默认值


    @Schema(description = "排序方式，升序或降序，默认升序", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "asc", allowableValues = {"asc", "desc"})
    @Pattern(regexp = "^(asc|desc)$", message = "排序方式只能是asc或desc")
    private String orderBy = "asc";  // 设置默认值
}
    
